package com.Cychat.pet.service.impl;

import com.Cychat.commons.entity.pojo.Pet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.Cychat.pet.mapper.PetMapper;
import com.Cychat.pet.service.PetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Auther: 谢宝辉  <br/>
 * Date: 2025/10/30:17:40  <br/>
 * Description: 宠物服务实现类
 */
@Service
public class PetServiceImpl extends ServiceImpl<PetMapper, Pet> implements PetService {

    @Autowired
    private PetMapper petMapper;

    /**
     * Description : 根据用户ID查询宠物列表
     * ChangeLog : 1. 创建 (2025/10/30 17:46 [Lenovo]);
     * @auther: 谢宝辉
     * date: 2025/10/30:17:46
     * @param ownerId
     * @return java.util.List<com.Cychat.commons.entity.pojo.Pet>
    */
    @Override
    public List<Pet> getPetsByOwnerId(Integer ownerId) {
        LambdaQueryWrapper<Pet> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Pet::getOwnerId, ownerId);
        return list(queryWrapper);
    }

    /**
     * Description : 根据用户ID查询宠物主人ID
     * ChangeLog : 1. 创建 (2025/10/30 17:46 [Lenovo]);
     * @auther: 谢宝辉
     * date: 2025/10/30:17:46
     * @param userId
     * @return java.lang.Integer
    */
    @Override
    public Integer getPetOwnerIdByUserId(Long userId) {
        return petMapper.getPetOwnerIdByUserId(userId);
    }
}
